import React, { Component } from 'react'
import qs from 'querystring';

const DetailData = [
    {id:'01',content:"你好，001"},
    {id:'02',content:"你好，002"},
    {id:'03',content:"你好，003"}
]
export default class Detail extends Component {
    render() {
        // 接收params参数
        // let { id, title } = this.props.match.params;

        // 接收search参数
        // let { id, title } = qs.parse((this.props.location.search).slice(1));

        // 接收state参数
        let { id, title } = this.props.location.state || {};

        let findResult = DetailData.find(datoLiObj => {
            return datoLiObj.id === id;
        })|| {};
        return (
            <div>
                <ul>
                    <li>ID:{ id }</li>
                    <li>TITLE:{ title }</li>
                    <li>CONTENT:{ findResult.content }</li>
                </ul>
            </div>
        )
    }
}
